package cn.thornbird.orgsync.entity;

import cn.thornbird.orgsync.entity.status.AppType;
import cn.thornbird.orgsync.entity.status.ExecuteStatus;
import cn.thornbird.orgsync.entity.status.TaskFrequency;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Entity
@Table(name = "tasks")
@Where(clause = "deleted_at is null")
public class Task extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -4919083716229514391L;

    @Column(name = "title")
    private String title;

    @Column(name = "user_id")
    private String userId;

    @Column(name = "source_company_id")
    private String sourceCompanyId;

    @Column(name = "source_app_type")
    private AppType sourceAppType;

    @Column(name = "source_department_id")
    private String sourceDepartmentId;

    @Column(name = "source_department_name")
    private String sourceDepartmentName;

    @Column(name = "target_company_id")
    private String targetCompanyId;

    @Column(name = "target_app_type")
    private AppType targetAppType;

    @Column(name = "target_department_id")
    private String targetDepartmentId;

    @Column(name = "target_department_name")
    private String targetDepartmentName;

    @Column(name = "default_password")
    private String defaultPassword;

    @Column(name = "including_children")
    private Boolean includingChildren;

    @Column(name = "including_employees")
    private Boolean includingEmployees;

    @Column(name = "delete_non_existent_children")
    private Boolean deleteNonExistentChildren;

    @Column(name = "active")
    private Boolean active;

    @Column(name = "frequency")
    private TaskFrequency frequency;

    @Column(name = "day_of_week")
    private Short dayOfWeek;

    @Column(name = "day_of_month")
    private Short dayOfMonth;

    @Column(name = "hour")
    private Short hour;

    @Column(name = "minute")
    private Short minute;

    @Column(name = "max_retry_count")
    private Short maxRetryCount;

    @Column(name = "retry_interval")
    private Short retryInterval;

    @Column(name = "remark")
    private String remark;

    @Column(name = "batch_count")
    private Integer batchCount;

    @Column(name = "success_batch_count")
    private Integer successBatchCount;

    @Column(name = "last_plan_time")
    private Date lastPlanTime;

    @Column(name = "last_execute_status")
    private ExecuteStatus lastExecuteStatus;

    @Column(name = "last_retry_count")
    private Short lastRetryCount;

    @Column(name = "last_start_time")
    private Date lastStartTime;

    @Column(name = "last_end_time")
    private Date lastEndTime;

}
